<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<x:parse xml="${param.xmlstr}" var="xmlData" />
<div class="t_bar">附件列表</div>
		<table id="prp_attachs" label="附件" border="0" cellspacing="0" cellpadding="0" class="table01 t_css" style="*border-bottom: #a1c0dc 1px solid;">
				<thead>
					<tr>
						<th width="40px">选择</th>
						<th width="40px">序号</th>
						<th width="200px">附件类型</th>
						<th width="100px">附件名称</th>
						<th>上传日期</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					
					<tr style="display: none" >
						<td nowrap=true align="center" >
							<input type="radio" name="sel_attachs" class="do">	 
						</td>
						<td align="center">
							<span name="prp_attachs|prp_attach[0]@seq_no">[index]</span>
						</td>
						<td>
			                <select id="attachtype_[0]" onChange="myinitControlValue(this.id)"><option value=""></option></select>
			                <input type="hidden" id="attachtype_[0]_value" name="prp_attachs|prp_attach[0]|attachtype_value" class="required" label="附件类型" />
			                <input type="hidden" id="attachtype_[0]_name" name="prp_attachs|prp_attach[0]|attachtype_name"  />
		                </td>
						<td>
							<input type="text"  name="prp_attachs|prp_attach[0]|name" class="input_text required" maxlength=50 style="width:100px" label="附件名称" value="" />
						</td>
						<td align="left">
							<input type="hidden"  name="prp_attachs|prp_attach[0]|entity_file_name" />
							<input type="hidden"  name="prp_attachs|prp_attach[0]|file_code" />
							<span name="prp_attachs|prp_attach[0]|file_date"></span>
						</td>
						<td>		
						</td>
					</tr>
					<c:set value="0" var="index" scope="page" />
					<x:forEach select="$xmlData/data/prp_attachs/prp_attach" var="prp_attach">
						<c:choose>
							<c:when test="${index<10}">
								<c:set value="0" var="flag" scope="page" />
							</c:when>
							<c:otherwise>
								<c:set value="" var="flag" scope="page" />
							</c:otherwise>
						</c:choose>
						<tr>
							<td nowrap=true  align="center" >
								<input type="radio" name="sel_attachs" class="do">
							</td>
							<td align="center">
								<span name="prp_attachs/prp_attach[${flag}${index}]@seq_no"><x:out select="$prp_attach/@seq_no" /></span>
							</td>
							<td>
			                    <select id="attachtype_[${flag}${index}]" onChange="myinitControlValue(this.id)"><option value=""></option></select>
			                    <input type="hidden"  id="attachtype_[${flag}${index}]_value" name="prp_attachs/prp_attach[${flag}${index}]/attachtype_value" class="required" label="附件类型" value="<x:out select="$prp_attach/attachtype_value" />"/>
			                    <input type="hidden"  id="attachtype_[${flag}${index}]_name" name="prp_attachs/prp_attach[${flag}${index}]/attachtype_name"  value="<x:out select="$prp_attach/attachtype_name" />"/>
		                    </td>
							<td>
								<input type="text" name="prp_attachs/prp_attach[${flag}${index}]/name" value="<x:out select="$prp_attach/name" />" class="input_text required" maxlength=50  style="width:100px" label="附件名称"  />
							</td>
							<td align="left">
								<input type="hidden"  name="prp_attachs/prp_attach[${flag}${index}]/file_code"  value="<x:out select="$prp_attach/file_code" />"/>
								<input type="hidden"  name="prp_attachs/prp_attach[${flag}${index}]/entity_file_name"  value="<x:out select="$prp_attach/entity_file_name" />"/>
								<input type="hidden"  name="flag_upload" value="0"/>	
								<span name="prp_attachs/prp_attach[${flag}${index}]/file_date"><x:out select="$prp_attach/file_date" /></span>
							</td>
							<td>
								<c:set var="fileCode">
									<x:out select="$prp_attach/file_code" />
								</c:set> 
								<c:set var="etyfileName">
									<x:out select="$prp_attach/entity_file_name" />
								</c:set> 
								<c:if test="${fileCode!=''}">									
									<a href="${ctx}/file/ajax-filedownload?fileCode=${fileCode}" ><span class="color_blue" >下载文件(${etyfileName})</span></a>
								</c:if> 
							</td>
						</tr>
						<c:set value="${index+1}" var="index" scope="page" />		
					</x:forEach>
				</tbody>
			</table>
		<br/>
		<table width="100%" align="center" id="attachAdd">
			<tr>
				<td>
					<input type="file" name="filedata" id="fileuploadid" />
					<!-- <input class="button_02"  type="button" value="添加" onclick="addNewRow('prp_attachs');loadAttachType('prp_attachs','attach_type','');fileTrInit('prp_attachs',150);try{top.resizeFrame();}catch(e){};">-->
					<!-- &nbsp;<input class="button_02" type="button" value="上传" onclick="uploadAttachs('attachAdd');"> -->
					&nbsp;<input class="button_02" type="button" value="上移" onclick="movePrev('prp_attachs')">
					&nbsp;<input class="button_02" type=button value="下移" onclick="moveNext('prp_attachs')">
					&nbsp;<input class="button_02" name="cmddel" id="cmddelPsn" type=button value="删除" onclick="deleteSelectedRow('prp_attachs','附件');">
				</td>
			</tr>
		</table>
		<br>
		<table>
			<!-- 
		    <tr>
			    <td>
				   <b>一、附件材料说明：&nbsp;</b><br>
				   1.本项目附件限传20个以内；<br/>
				   2.5篇代表性论著复印件（提示：请将每篇论著单独做附件上传）；<br>
				   3.如曾获科技奖励，提供国家级科技奖励（国家自然科学奖、国家发明奖、国家科学技术进步奖）、省部级奖励（二等以上）和国家学术性奖励证书扫描文件；<br>
				   4.如获专利或其他公认突出的创造性成果或成绩，应提供证明材料的扫描文件；<br>
				   5.在国家学术会议上作大会报告、特邀报告，应提供邀请信或通知的扫描文件。
			    </td>
		     </tr>
		      -->
		     <tr>
			    <td>
				   <b>附件添加操作说明：&nbsp;</b><br>
				   1.点击“增加新附件”按钮进行附件添加；<br>
				   2.点击“上移”或“下移”按钮进行附件排列调整；<br>
				   3.点击“删除”按钮进行附件删除；<br>
				   4.本项目附件限传20个以内；<br/>
			    </td>
		     <tr>
		        <td>
				    <font style="color: red"><b>上传文件大小不能超过3M，若文件超过，建议分几部分上传，允许上传文件类型：JPG，PDF。</b></font>
		        </td>
		     </tr>
	    </table>
<script type="text/javascript">
     $(document).ready(function(){
    	 var key="attach_type";
    	 var grant_code = $("input[name='proposal/grant_code']").val();
    	 var sub_grant_code = $("input[name='proposal/sub_grant_code']").val();
    	 var help_grant_code = $("input[name='proposal/help_grant_code']").val();
    	
    	 $("#prp_attachs tr:gt(1)").each(function(){
    		 var obj=$(this).find('td').find("select");
    		 var selectid=changeString(obj.attr("id"));
    		 
    		 var value=$("#"+selectid).parent().children("input[id$='"+selectid+"_value'][type='hidden']").val();
    		 loadAjaxSelect(selectid,"/egrantweb/cpt/ajaxload-select",{"locale":"zh_CN","key":key,"cacheable":"false","sqlParamVal":"{'grant_code':'"+grant_code+"','sub_grant_code':'"+sub_grant_code+"','help_grant_code':'"+help_grant_code+"'}"},value);    		 
    	 });
     });
</script>